package io.github.biezhi.adapterClass;

/**
 * 1. 类适配器模式
 * 类适配器模式通过继承目标接口（或抽象类）并实现源接口（或具体类）来完成适配
 */

// 源接口（需要适配的接口）
interface TargetInterface {
    void request();
}

// 目标接口（期望的接口）
interface AdapteeInterface {
    void specificRequest();
}

// 具体源类（被适配类
class ConcreteAdaptee implements AdapteeInterface {
    @Override
    public void specificRequest() {
        System.out.println("Adaptee: Handling specific request");
    }
}

// 类适配器
class ClassAdaptee extends ConcreteAdaptee implements TargetInterface {
    @Override
    public void request() {
        specificRequest();
        System.out.println("Adapter: Additional processing after calling specific request");
    }
}

public class AdapterClass {
    public static void main(String[] args) {
        ClassAdaptee adaptee = new ClassAdaptee();
        adaptee.request();
    }
}
